#include "comm/znx_array.h"
#include "comm/znx_log.h"

typedef struct {
    int         a;
    int         b;
    int         c;
} znx_item_t;

int main()
{
    znx_item_t *item, *items;

    znx_array_t *arr =
        znx_array_create(0, sizeof(znx_item_t));
    znx_array_destroy(arr);

    arr = znx_array_create(0, sizeof(znx_item_t));
    for (int i = 0; i < 64; i++) {
        item = znx_array_push(arr);
        item->a = i;
        item->b = i;
        item->c = i;
    }

    if (arr->nelts != 64) {
        ZNX_DEF_LOG_FATAL(NULL, "expect 64, but got %d", arr->nelts);
    }

    znx_array_pop(arr);
    znx_array_pop(arr);
    znx_array_remove(arr, 0);
    znx_array_remove(arr, 1);

    items = arr->elts;
    for (uint64_t i = 0; i < arr->nelts; i++) {
        item = items + i;
        if (item->a == 0 || item->a == 2 || item->a == 62 || item->a == 63) {
            ZNX_DEF_LOG_FATAL(NULL, "unexpect result");
        }
    }

    znx_array_destroy(arr);

}